package com.yilouwangye.proxy.exmple_2;

public class UserServiceProxy implements UserService{
    UserServiceImpl userService = new UserServiceImpl();

    public void setUserService(UserServiceImpl userService) {
        this.userService = userService;
    }

    public void add() {
        log("add");
        userService.add();
    }

    public void delete() {
        log("del");
        userService.delete();
    }

    public void update() {
        log("update");
        userService.update();
    }

    public void query() {
        log("select");
        userService.query();
    }

    void log(String str){
        System.out.println("sqlServer start process " + str + "...");
    }

    public static void main(String[] args) {
        UserServiceImpl userService = new UserServiceImpl();
        UserServiceProxy proxy= new UserServiceProxy();
        proxy.setUserService(userService);
        proxy.add();
    }
}
